<!DOCTYPE html>
<html ng-app="myApp">
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <!--[if lt IE 9]>
    <script type="text/javascript" src="../../../lib/html5shiv.js?rev=@@hash"></script>
    <script type="text/javascript" src="../../../lib/respond.min.js?rev=@@hash"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="../../../static/h-ui/css/H-ui.min.css"/>
    <link rel="stylesheet" type="text/css" href="../../../static/h-ui.admin/css/H-ui.admin.css"/>
    <link rel="stylesheet" type="text/css" href="../../../lib/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="../../../static/h-ui.admin/skin/default/skin.css" id="skin"/>
    <link rel="stylesheet" type="text/css" href="../../../static/h-ui.admin/css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../../../ht-css/Project.css"/>
    <link rel="stylesheet" type="text/css" href="../../../lib/Validform/5.3.2/style.css"/>
    <!--引入分页-->
    <link rel="stylesheet" href="../../../lib/pagination/pagination.css">
    <!--[if IE 6]>
    <script type="text/javascript" src="../../../lib/DD_belatedPNG_0.0.8a-min.js?rev=@@hash"></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="../../../ht-css/style-q.css"/>
    <title>Code详情</title>
    <style>
        html {
            zoom: .80
        }
    </style>
</head>
<body ng-controller="skuDetailCtrl">
<nav class="breadcrumb">商品管理 <span class="c-gray en">&gt;</span> 分类/品牌设置 <span class="c-gray en">&gt;</span> 商品售卖管 <span
        class="c-gray en">&gt;</span> SKU<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
                                            href="javascript:location.replace(location.href);" title="刷新"><i
        class="Hui-iconfont">&#xe68f;</i></a></nav>
<article class="page-container">
    <form class="ml-20 mr-20" id="sku"    method="post">
        <div class="ml-20 mr-20" id="spuInfo">
            <div id="tab_topnav" class="HuiTab">
                <div class="tabBar clearfix"><span>商品售卖管理</span><!--<span>商品图片管理</span>--></div>
                <!--SKU详情-->
                <div id="tabCon" class="tabCon bg-1 bk-gray pd-20 mb-20">
                    <div class="va-m lh-20 f-16 pb-15">
                        <strong>详情表</strong>
                    </div>
                    <div class="line"></div>
                    <div class="pd-20 mb-20">
                        <tr>
                            <td class="col-4-1">商品SPU码：
                                <span class="mr-30" id="spu_code">{{skuItems.spu_code}}</span>
                            </td>
                            <!-- <td class="col-4-1">SKU码：
                                 <span class="mr-30" id="sku_code">{{skuItems.sku_code}}</span>
                             </td>-->

                            <td class="col-4-1">Code码：<span>{{skuItems.product_code}}</span></td>
                        </tr>
                        <div class="mb-15" > 商品名称：<span><input type="hidden" id="skuName" class="input-text radius" style="width: 160px;height: 26px" value="{{skuItems.sku_name}}">{{skuItems.sku_name}}&nbsp;{{skuItems.sale_attri_value}}</span></div>

                        <div class="mb-15"> 商品别名：<span>{{skuItems.alias_value}}</span></div>

                        <div class="mb-15"> 品牌名称：<span>{{skuItems.brand_name}}</span></div>
                        <div class="mb-15"> 货号：<span>{{skuItems.productNumber}}</span></div>

                        <div class="mb-15"> 商品副标题：<span>{{skuItems.subtitile}}</span></div>

                        <div class="mb-15">所属分类：<span>{{skuItems.category_name}}</span>
                        </div>
                        <div class="mb-15 clearfix">
                            <span class="f-l">场景标签：</span><span onmouseover="showAllScene()" onmouseout="hideAllScene()" class="lableName" style="max-width: 600px;height: 20px;overflow: hidden;float: left;"></span>
                        </div>


                        <div class="mb-15"> 是否限制类：<span>{{skuItems.restricted}}</span></div>
                        <div class="mb-15"> 商品标准：<span>{{skuItems.standards}}</span>
                            <span class="gbnumber">{{skuItems.unionStandardsNumber}}</span>
                        </div>
                        <div class="mb-15"> 客户类型可见：<span>{{skuItems.customer_type}}</span></div>
                        <div class="mb-15"> 件装数量：<span>{{skuItems.parts_number}}</span></div>
                        <div class="mb-15">
                            <span class="c-red pr-5 f-l">*</span>
                            购买限制类型：
                            <input type="radio" name="orderLimitType" id="orderInteger" value="1" onchange="orderLimitChange()">
                            <label for="orderInteger">不低于起订量的正整数</label> &nbsp;&nbsp;&nbsp;&nbsp;

                            <input type="radio" name="orderLimitType" id="orderIntegerTimes" value="0" onchange="orderLimitChange()">
                            <label for="orderIntegerTimes">起订量的正整数倍</label>
                        </div>
                        <div class="mb-15">
                            <span class="c-red pr-5 f-l">*</span>
                            最小起订量：
                            <input type="text" id="miniOrder" onkeyup="validateNum()" onblur="validateNull()" class="input-text radius" style="width: 160px;height: 26px" value="">
                            <span>{{skuItems.unit_name}}</span>
                            <input type="hidden" id="miniOrderVol" class="input-text radius" style="width: 160px;height: 26px" value="">
                        </div>
                        <div class="va-m lh-20 f-16 pb-15">
                            <strong>商品尺寸(单品)</strong>
                        </div>
                        <div class="mb-15"> 最长边：<span>{{skuItems.maxLength}}</span></div>
                        <div class="mb-15"> 次长边：<span>{{skuItems.subLength}}</span></div>
                        <div class="mb-15"> 体积：<span>{{skuItems.Volume}}</span></div>
                        <div class="mb-15"> 重量：<span>{{skuItems.weight1}}</span></div>
                    </div>

                    <div class="va-m lh-20 f-16 pb-15">
                        <strong>商品描述信息字段</strong>
                    </div>
                    <div class="line"></div>
                    <table id="attrTable"  class="table table-border table-bordered table-bg mt-15 mb-30">
                        <thead>
                        <tr>
                            <th class="col-6-1 text-c">规格名称</th>
                            <td>{{skuItems.sale_attri_value}}</td>
                        </tr>
                        <tr>
                            <th class="col-6-1 text-c">销售属性-颜色</th>
                            <td>
                                <!--{{skuItems.color}}-->
                                <input type="text" id="skuColor" disabled class="input-text radius" style="width: 160px;height: 26px" value="{{skuItems.color}}">
                            </td>
                        </tr>
                        <tr>
                            <th class="col-6-1 text-c">重量</th>
                            <td>{{skuItems.weight}}</td>
                        </tr>
                        <tr>
                            <th class="col-6-1 text-c">型号</th>
                            <td>{{skuItems.model}}</td>
                        </tr>
                        <tr>
                            <th class="col-6-1 text-c">销售属性-规格</th>
                            <td>
                                <!--{{skuItems.specifications}}-->
                                <input type="text" id="skuSpecifications"  disabled class="input-text radius" style="width: 160px;height: 26px" value="{{skuItems.specifications}}">
                            </td>
                        </tr>
                        </thead>
                    </table>

                    <div class="va-m lh-20 f-16 pb-15">
                        <strong>图片信息</strong>
                        <a href="javascript:location.replace(location.href);" onclick="extendSpuImg();" ><span
                                class="btn btn-secondary radius size-S botter ">使用SPU图片</span></a>
                        <!--<a href="javascript:;" onclick="extendSpuImg()"  ><span
                                class="btn btn-secondary radius size-S botter ">使用SPU图片</span></a>-->
                    </div>
                    <div class="line"></div>
                    <div class="mt-15 mb-30 imgTable clearfix">
                        <ul class="imgboxUl f-l">
                        </ul>
                        <ul class="f-l ml-5 addSpuImgbox">
                            <li class="col-5-1 text-c va-t">
                            <span id="addSpuImg" class="spu_add_img"  >
                            </span>
                            </li>
                        </ul>
                    </div>

                    <div class="va-m lh-20 f-16 pb-15">
                        <strong>详情信息</strong>
                    </div>
                    <div class="line"></div>
                    <div class="pd-20">
                        <script id="editor" type="text/plain" style="width: 100%; height: 500px;"></script></div>
                    <div class="text-c mb-10">
                        <!--<input id="sureBtn" type="button" onclick="makeSure()" class="btn btn-secondary radius size-S botter" value="&nbsp;确&nbsp;&nbsp;认&nbsp;">-->
                        <input type="button" class="btn radius size-S botter ml-10" onclick="cancleSku()" value="&nbsp;取&nbsp;&nbsp;消&nbsp;">
                    </div>
                </div>

                <!--商品图片管理-->
                <div class="tabCon pd-5 bg-1 bk-gray pb-10">
                    <div class="lh-30 pd-10">
                        <form name="name2" id="picForm">
                            <table class="table-hover table_li ml-10 mb-10 table">
                                <thead class="text-l">
                                <tr>
                                    <td colspan="3" class="col-1-1">
                                        <div class="row ml-10">
                                            <label class="form-label f-l pt-5">商品分类：</label>
                                            <span class="size-M radius col-xs-8 f-l" style="width:15%">
                            <div style="position: relative;z-index: 900;">
                            <input type="text" autocomplete="off" class="input-text radius"
                                   name="imgClass1" placeholder="请选择一级分类"
                                   oninput="imgGoods_listCategory(1)" id="imgClass1" datatype="/^[a-zA-Z0-9\u4e00-\u9fa5、]{0,11}$/"
                                   errormsg="格式错误，请重新输入" ignore="ignore">
                            <ul class="relation radius guanlian" id="img-classUl1">

                            </ul>
                            </div>
                            <span class="Validform_checktip"></span>
                            </span>
                                            <span class="f-l pl-10 pr-10 pt-5">~</span>
                                            <span class="size-M radius col-xs-8 f-l" style="width:15%">
                            <div style="position: relative;z-index: 900;">
                            <input type="text" autocomplete="off" class="input-text radius"
                                   name="imgClass2" placeholder="请选择二级分类" id="imgClass2" datatype="/^[a-zA-Z0-9\u4e00-\u9fa5、]{0,11}$/"
                                   errormsg="格式错误，请重新输入" ignore="ignore">
                            <ul class="relation radius guanlian" id="img-classUl2">
                            </ul>
                            </div>
                            <span class="Validform_checktip"></span>
                            </span>
                                            <span class="f-l pl-10 pr-10 pt-5">~</span>
                                            <span class="size-M radius col-xs-8" style="width:15%">
                            <div style="position: relative;z-index: 900;">
                            <input type="text" autocomplete="off" class="input-text radius"
                                   name="imgClass3" placeholder="请选择三级分类" id="imgClass3" datatype="/^[a-zA-Z0-9\u4e00-\u9fa5、]{0,11}$/"
                                   errormsg="格式错误，请重新输入" ignore="ignore">
                            <ul class="relation radius guanlian" id="img-classUl3">
                            </ul>
                            </div>
                            <span class="Validform_checktip"></span>
                            </span>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="col-3-1">
                                        <div class="row ml-10">
                                            <label class="form-label f-l pt-5">图片名称：</label>
                                            <div class="formControls col-xs-8 col-sm-9">
                                                <input type="text" class="input-text radius" name="imgname" id="imgName"
                                                       placeholder="输入图片名称关键字" datatype="/^[a-zA-Z0-9\u4e00-\u9fa5]{0,50}$/"
                                                       errormsg="格式错误，请重新输入" ignore="ignore">
                                            </div>
                                            <span class="Validform_checktip"></span>
                                        </div>
                                    </td>
                                    <td class="col-3-1">
                                        <div class="row ml-10">
                                            <label class="form-label f-l pt-5">SPU码：</label>
                                            <div class="formControls col-xs-8 col-sm-9">
                                                <input type="text" class="input-text radius" name="spuCode" id="spuCode"
                                                       placeholder="输入SPU码" datatype="n0-11" errormsg="格式错误，请重新输入"
                                                       ignore="ignore">
                                            </div>
                                            <span class="Validform_checktip"></span>
                                        </div>
                                    </td>
                                    <td class="col-3-1">
                                        <div class="row ml-10">
                                            <label class="form-label f-l pt-5">SKU码：</label>
                                            <div class="formControls col-xs-8 col-sm-9" >
                                                <input type="text"  class="input-text radius"  name="skuCode"  id="skuCode"
                                                       placeholder="输入SKU码" datatype="n0-11"  errormsg="格式错误，请重新输入"
                                                       ignore="ignore">
                                            </div>
                                            <span class="Validform_checktip"></span>
                                        </div>
                                    </td>
                                </tr>
                                </thead>
                            </table>
                            <div class="text-c mb-10">
                                <input id="btn" type="submit" class="btn btn-secondary radius size-S botter"
                                       value="&nbsp;查&nbsp;&nbsp;询&nbsp;">
                                <input name="" type="reset" onclick="resetDiv()" class="btn radius size-S botter ml-10"
                                       value="&nbsp;重&nbsp;&nbsp;置&nbsp;">
                            </div>
                        </form>
                        <div class="text-l pl-20 pb-10 clearfix"><input class="btn radius btn-secondary-outline radius f-l"
                                                                        onclick="addImg()"  type="button" value="新增"></div>
                        <div class="line"></div>
                        <ul id="imgListBox" class="sale_pic clearfix">
                        </ul>
                        <div class="dataTables_wrapper goods_fanye clearfix">
                            <div class="f-r pageturning M-box3"></div>
                            <div class="dataTables_paginate paging_simple_numbers"><a class="paginate_button previous disabled">前一页</a><a class="paginate_button current">1</a><a class="paginate_button">2</a><a class="paginate_button">3</a><span>...</span><a class="paginate_button">10</a><a class="paginate_button next">后一页</a></div>-->
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
</article>
</body>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="../../../lib/jquery/1.9.1/jquery.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/layer/2.4/layer.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../static/h-ui/js/H-ui.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../static/h-ui.admin/js/H-ui.admin.js?rev=@@hash"></script> <!--/_footer 作为公共模版分离出去-->
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="../../../lib/My97DatePicker/4.8/WdatePicker.js?rev=@@hash"></script>
<!--富文本编辑器-->
<script type="text/javascript" charset="utf-8" src="../../../lib/ueditor/1.4.3/ueditor.config.js?rev=@@hash"></script>
<script type="text/javascript" charset="utf-8" src="../../../lib/ueditor/1.4.3/ueditor.all.min.js?rev=@@hash"> </script>
<!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
<script type="text/javascript" charset="utf-8" src="../../../lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js?rev=@@hash"></script>
<!--表单验证-->
<script type="text/javascript" src="../../../lib/jquery.validation/1.14.0/jquery.validate.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/jquery.validation/1.14.0/validate-methods.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/jquery.validation/1.14.0/messages_zh.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/datatables/1.10.0/jquery.dataTables.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/laypage/1.2/laypage.js?rev=@@hash"></script>
<!--表单验证-->
<script type="text/javascript" src="../../../lib/Validform/5.3.2/Validform_v5.3.2_min.js?rev=@@hash"></script>
<script src="../../../lib/pagination/jquery.pagination.js?rev=@@hash"></script>
<script src="../../../ht-js/coupon/coupon-topic.js?rev=@@hash"></script>
<script src="../../../ht-js/public.js?rev=@@hash"></script>
<!--验证token-->
<script src="../../../ht-js/verifyToken.js?rev=@@hash"></script>
<script src="../../../ht-js/goods/sku-info.js?rev=@@hash"></script>
<script src="../../../lib/angular.min.js?rev=@@hash"></script>
<script src="../../../ht-js/goods/goods-list.js?rev=@@hash"></script>
<script>
    var areaId = 2;
    $("#addSpuImg").click(function () {
        var imgLength = document.getElementsByClassName("imgboxUl")[0].children.length;
        sessionStorage.setItem("imgLength", JSON.stringify(imgLength));
        if(sessionStorage.getItem("skuImgCache")){
            var getSkuImgCache = sessionStorage.getItem("skuImgCache");
            var skuInfoImg = JSON.parse(getSkuImgCache);
            var skuInfoImgArr = Object.keys(skuInfoImg);
            addPic((skuInfoImgArr.length + 1), true);
        }
    });

    $(function () {
        $("#picForm").Validform({
            tiptype: 2,
            callback: function (form) {
                img_list();
                return false;
            }
        });
    });
    var app = angular.module('myApp', []);
    app.controller('skuDetailCtrl', function ($scope, $http) {
        var sku_Id = getQueryString('sku_Id');
        $http({
            method: 'POST',
            url: root.goodsInter.goods_getSkuDetail,
            data: {
                skuId: sku_Id,
            }
        }).then(function successCallback(response) {
            // 请求成功执行代码
            if (sessionStorage.getItem("scene_lable")) {
                var lable_name = JSON.parse(sessionStorage.getItem("scene_lable"));
                console.log(lable_name)
                var lableHtmlStr = "";
                for (var i=0;i<lable_name.length;i++){
                    lableHtmlStr+="<span>"+lable_name[i].class1 + '>' + lable_name[i].class2+"</span><a onclick='deleteScene("+i+")' class='Hui-iconfont' style='color: grey'>&#xe6a6;</a>&nbsp;&nbsp;"
                }
                $(".lableName").html(lableHtmlStr);
            } else {
                var lableHtmlStr = "";
                var scene_lable = [];
                for(var i=0;i<response.data.data.lable_name.length;i++){
                    var lableNameArr = {
                        class1: response.data.data.lable_name[i].ParentlableName,
                        class2: response.data.data.lable_name[i].lableName,
                        lableId1: response.data.data.lable_name[i].parent_lable_id,
                        lableId2: response.data.data.lable_name[i].lable_id
                    };
                    scene_lable.push(lableNameArr)
                }
                sessionStorage.setItem("scene_lable", JSON.stringify(scene_lable));
                for (var i=0;i<scene_lable.length;i++){
                    lableHtmlStr+="<span>"+scene_lable[i].class1 + '>' + scene_lable[i].class2+"</span><a onclick='deleteScene("+i+")' class='Hui-iconfont' style='color: grey'>&#xe6a6;</a>&nbsp;&nbsp;"
                }
                $(".lableName").html(lableHtmlStr);
            }

            /*判断购买限制类型*/
            if(sessionStorage.getItem("mini_order") && sessionStorage.getItem("order_limit_type")){
                var mini_order = JSON.parse(sessionStorage.getItem("mini_order"));
                var order_limit_type = JSON.parse(sessionStorage.getItem("order_limit_type"));
                if(order_limit_type == '0'){
                    $("#orderIntegerTimes").prop("checked",true)
                }else if (order_limit_type == '1'){
                    $("#orderInteger").prop("checked",true)
                }

                document.getElementById("miniOrder").value = mini_order;
            } else {
                sessionStorage.setItem("mini_order", response.data.data.mini_order);
                sessionStorage.setItem("order_limit_type", response.data.data.order_limit_type);
                if(response.data.data.order_limit_type == '0'){
                    $("#orderIntegerTimes").prop("checked",true)
                }else if (response.data.data.order_limit_type == '1'){
                    $("#orderInteger").prop("checked",true)
                }
            }
            /*拼接别名+销售属性*/
            if (response.data.data.alias_value != null && response.data.data.alias_value != ''){
                var aliasArray = response.data.data.alias_value.split(";");
                var array = [];
                for (var i = 0; i < aliasArray.length; i++){
                    var str;
                    str = aliasArray[i] + " " + response.data.data.sale_attri_value;
                    array.push(str)
                }
                response.data.data.alias_value = array.join(";");
            }
            $scope.skuItems = response.data.data;
            response.data.data.miniOrders.forEach((item) => {
                if(item.saleAreaId == areaId){
                    $("#miniOrder").val(item.miniOrderNum);
                    $("#miniOrderVol").val(item.miniOrderNum);
                }
            })
        }, function errorCallback(response) {
            // 请求失败执行代码
            alert("请求数据失败！");
        });
    }).config(function ($httpProvider) {
        $httpProvider.defaults.transformRequest = function (obj) {
            var str = [];
            for (var p in obj) {
                str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
            }
            return str.join("&");
        };
        $httpProvider.defaults.headers.post = {
            'Content-Type': 'application/x-www-form-urlencoded'
        }

    });

    function showAllScene() {
        $(".lableName").css({
            overflow:"visible"
        })
    }
    function hideAllScene() {
        $(".lableName").css({
            overflow:"hidden"
        })
    }
    function deleteScene(index){
        var lable_name = JSON.parse(sessionStorage.getItem("scene_lable"));
        lable_name.splice(index, 1);
        sessionStorage.setItem("scene_lable",JSON.stringify(lable_name))
        var lableHtmlStr = "";
        for (var i=0;i<lable_name.length;i++){
            lableHtmlStr+="<span>"+lable_name[i].class1 + '>' + lable_name[i].class2+"</span><a onclick='deleteScene("+i+")' class='Hui-iconfont' style='color: grey'>&#xe6a6;</a>&nbsp;&nbsp;"
        }
        $(".lableName").html(lableHtmlStr);
    }
    jQuery.Huitab = function (tabBar, tabCon, class_name, tabEvent, i) {
        var $tab_menu = $(tabBar);
        // 初始化操作
        $tab_menu.removeClass(class_name);
        $(tabBar).eq(i).addClass(class_name);
        $(tabCon).hide();
        $(tabCon).eq(i).show();

        $tab_menu.bind(tabEvent, function () {
            $tab_menu.removeClass(class_name);
            $(this).addClass(class_name);
            var index = $tab_menu.index(this);
            $(tabCon).hide();
            $(tabCon).eq(index).show()
        })
    }
    $(function () {
        $.Huitab("#tab_topnav .tabBar span", "#tab_topnav .tabCon", "current", "click", "0")
    });

    // 场景标签
    function label_choice(title, url, w, h) {
        layer_show(title, url, w, h);
    }


    // 提示信息
    function showmsg(msg, icon) {
        layer.msg(msg, {
            icon: icon,
            time: 1000
        }, function () {
            if (icon == 6) {
                var index = parent.location.reload();
                parent.layer.close(index);
            }
        });
    }
    var skuFormData = new FormData();
    var sku_Id = getQueryString('sku_Id');
    var spuImgCount = 0;
    //实例化编辑器
    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
    var ue = UE.getEditor('editor',{
        toolbars: [
            [
                'source', //源代码
                'anchor', //锚点
                'undo', //撤销
                'redo', //重做
                'bold', //加粗
                'indent', //首行缩进
                // 'snapscreen', //截图
                'italic', //斜体
                'underline', //下划线
                'strikethrough', //删除线
                'subscript', //下标
                'fontborder', //字符边框
                'superscript', //上标
                'formatmatch', //格式刷

                'blockquote', //引用
                'pasteplain', //纯文本粘贴模式
                'selectall', //全选
                'print', //打印
                'preview', //预览
                'horizontal', //分隔线
                'removeformat', //清除格式
                'time', //时间
                'date', //日期
                'unlink', //取消链接
                'insertrow', //前插入行
                'insertcol', //前插入列
                'mergeright', //右合并单元格
                'mergedown', //下合并单元格
                'deleterow', //删除行
                'deletecol', //删除列
                'splittorows', //拆分成行
                'splittocols', //拆分成列
                'splittocells', //完全拆分单元格
                'deletecaption', //删除表格标题
                'inserttitle', //插入标题
                'mergecells', //合并多个单元格
                'deletetable', //删除表格
                'cleardoc', //清空文档
                'insertparagraphbeforetable', //”表格前插入行”
                'insertcode', //代码语言
                'fontfamily', //字体
                'fontsize', //字号
                'paragraph', //段落格式
                /*'simpleupload', //单图上传
                'insertimage', //多图上传*/
                'edittable', //表格属性
                'edittd', //单元格属性
                'link', //超链接
                'emotion', //表情
                'spechars', //特殊字符
                'searchreplace', //查询替换
                'map', //Baidu地图
                'gmap', //Google地图
                'insertvideo', //视频
                'help', //帮助
                'justifyleft', //居左对齐
                'justifyright', //居右对齐
                'justifycenter', //居中对齐
                'justifyjustify', //两端对齐
                'forecolor', //字体颜色
                'backcolor', //背景色
                'insertorderedlist', //有序列表
                'insertunorderedlist', //无序列表
                'fullscreen', //全屏
                'directionalityltr', //从左向右输入
                'directionalityrtl', //从右向左输入
                'rowspacingtop', //段前距
                'rowspacingbottom', //段后距
                'pagebreak', //分页
                'insertframe', //插入Iframe
                'imagenone', //默认
                'imageleft', //左浮动
                'imageright', //右浮动
                // 'attachment', //附件
                'imagecenter', //居中
                'wordimage', //图片转存
                'lineheight', //行间距
                'edittip ', //编辑提示
                'customstyle', //自定义标题
                'autotypeset', //自动排版
                'webapp', //百度应用
                'touppercase', //字母大写
                'tolowercase', //字母小写
                'background', //背景
                'template', //模板
                'scrawl', //涂鸦
                'music', //音乐
                'inserttable', //插入表格
                'drafts', // 从草稿箱加载
                // 'charts', // 图表
            ]
        ]
    });
    UE.registerUI('dialog',function(editor,uiName){
            sessionStorage.setItem("skuOrSpu", "sku");
            //创建dialog
            var dialog = new UE.ui.Dialog({
                //指定弹出层中页面的路径，这里只能支持页面,因为跟addCustomizeDialog.js相同目录，所以无需加路径
                iframeUrl:'spuPictures.html',
                //需要指定当前的编辑器实例
                editor:editor,
                //指定dialog的名字
                name:uiName,
                //dialog的标题
                title:"请选择图片",

                //指定dialog的外围样式
                cssRules:"width:1366px;height:500px;",

                //如果给出了buttons就代表dialog有确定和取消
                buttons:[
                    {
                        className:'edui-okbutton',
                        label:'确定',
                        onclick:function () {
                            var selectNum = sessionStorage.getItem("selectNum");
                            if (selectNum != null) {
                                var selectPic = JSON.parse(sessionStorage.getItem("selectPic"));
                                var value = "";
                                for (var i = 0; i < selectPic.length; i++) {
                                    value += "<img src='" + selectPic[i] + "'>"
                                }
                                UE.getEditor('editor').execCommand('insertHtml', value)
                                sessionStorage.removeItem("selectNum");
                                sessionStorage.removeItem("selectPic");
                                dialog.close(true);
                            } else {
                                if(skuFormData!=null){
                                    if (sessionStorage.getItem("imgFileList") == 0) {
                                        layer.msg("请选择图片！", {icon: 5,time: 2000});
                                        return false;
                                    }
                                    $.ajax({
                                        url: root.goodsInter.goods_saveImages,
                                        cache: false,  //禁用缓存
                                        type: "POST",
                                        // 告诉jQuery不要去处理发送的数据
                                        processData: false,
                                        // 告诉jQuery不要去设置Content-Type请求头
                                        contentType: false,
                                        data: skuFormData,
                                        success: function (data) {
                                            if (data.errorCode == 0) {
                                                for(var i = 0; i < data.imgList.length; i++){
                                                    var value = "<img src='" + data.imgList[i].img_url + "'>";
                                                    UE.getEditor('editor').execCommand('insertHtml', value);
                                                }
                                                dialog.close(true);
                                            }
                                        }
                                    });
                                }
                            }

                        }
                    },
                    {
                        className:'edui-cancelbutton',
                        label:'取消',
                        onclick:function () {
                            sessionStorage.removeItem("selectNum");
                            sessionStorage.removeItem("selectPic");
                            dialog.close(false);
                        }
                    }
                ]
            });

            //参考addCustomizeButton.js
            var btn = new UE.ui.Button({
                name:'上传图片',
                title:'上传图片',
                //需要添加的额外样式，指定icon图标，这里默认使用一个重复的icon
                cssRules :'background-position: -726px -77px;',
                onclick:function () {
                    //渲染dialog
                    dialog.render();
                    dialog.open();
                }
            });
            return btn;
        }
        /*index 指定添加到工具栏上的那个位置，默认时追加到最后,editorId 指定这个UI是那个编辑器实例上的，默认是页面上所有的编辑器都会添加这个按钮*/);

    $.ajax({
        type: "POST",
        url: root.goodsInter.goods_getSkuDetail,
        cache: false,  //禁用缓存
        dataType: "json",
        data: {
            skuId: getQueryString('sku_Id')
        },
        success: function (result) {
            if (result.errorCode == 0) {
                sessionStorage.setItem("isSave", 1);// 修改是1 添加是0
                sessionStorage.setItem("skuInfo",JSON.stringify(result));
                var skuResult = JSON.parse(sessionStorage.getItem("skuInfo"));
                setTimeout(function(){
                    UE.getEditor('editor').setContent(skuResult.data.sku_detail, true);
                    UE.getEditor('editor').setContent(skuResult.data.spu_detail, true);
                },200);
                /*---------------------------------------属性处理开始----------------------------------------*/
                if(sessionStorage.getItem("attrObjCanch")){
                    var attrObjCanch = JSON.parse(sessionStorage.getItem("attrObjCanch"));
                    for(var i=0;i<attrObjCanch.length;i++){
                        var attrValStr="";
                        var attrIdsStr="";
                        if(attrObjCanch[i].value.length != 0){
                            for(var j=0;j<attrObjCanch[i].value.length;j++){
                                attrValStr += attrObjCanch[i].value[j].attri_value+";";
                                attrIdsStr +=attrObjCanch[i].value[j].attri_value_id+";";
                            }
                        }
                        $("#attrTable").append('<tr id = "appendSkuAttrSku"><th class="col-6-1 text-c">'+attrObjCanch[i].attribute_name+'</th><td><span>'+attrValStr+'</span><a onclick="addAttr('+attrObjCanch[i].attribute_id+",'"+attrIdsStr+"'"+')">添加</a></td></tr>')
                    }
                }else {
                    for(var i=0;i<skuResult.attrbuteValue.length;i++){
                        var attrValStr="";
                        var attrIdsStr="";
                        if(skuResult.attrbuteValue[i].value.length != 0){
                            for(var j=0;j<skuResult.attrbuteValue[i].value.length;j++){
                                attrValStr += skuResult.attrbuteValue[i].value[j].attri_value+";";
                                attrIdsStr += skuResult.attrbuteValue[i].value[j].attri_value_id+";";
                            }
                        }
                        $("#attrTable").append('<tr id="appendSkuAttr"><th class="col-6-1 text-c">'+skuResult.attrbuteValue[i].attribute_name+'</th><td><span>'+attrValStr+'</span><a onclick="addAttr('+skuResult.attrbuteValue[i].attribute_id+",'"+attrIdsStr+"'"+')">添加</a></td></tr>')
                    }
                }
                /*---------------------------------------属性处理结束----------------------------------------*/
                /*---------------------------------------图片处理开始----------------------------------------*/
                if(sessionStorage.getItem("skuImgCache")) {
                    var skuInfoImg =  JSON.parse(sessionStorage.getItem("skuImgCache"));
                    var skuInfoImgArr = Object.keys(skuInfoImg);
                    for (var i = 0; i < skuInfoImgArr.length; i++) {
                        var img = "img" + (i + 1);
                        $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="skuImg' + (i + 1) + '" class="sku_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\'' + skuInfoImg[img].imgUrl + '\')" src="' + skuInfoImg[img].imgUrl + '" width="150" height="150"></span><span id="skuImgId' + (i + 1) + '" style="display: none">' + skuInfoImg[img].imgId + '</span><span id="skuImgUrl' + (i + 1) + '" style="display: none">' + skuInfoImg[img].imgUrl +
                            '</span>' +
//                            '<div id="btnBox' + (i + 1) + '" class="pt-10 updataBtn"><a onclick="editPic(' + (i + 1) + ', false)" class="pd-20">修改</a>' +
//                            '<a onclick="deletePic(' + (i + 1) + ')" class="pd-20">删除</a>' +
                            '</div><div class="pd-20">排序&nbsp;&nbsp;&nbsp;<input type="text" class="input-text radius" onchange="checkRepeat(this, ' + (i + 1) + ')" value="' + skuInfoImg[img].imgSort + '" id="skuImgSort' + (i + 1) + '" name="imgSort" style="width:40px"></div></div>');                    }
                }else {
                    var skuImgCache = {};
                    var skuInfoImg = skuResult.spu_img;
                    spuImgCount = skuInfoImg.length;
                    for(var i = 0; i < skuInfoImg.length; i++){
                        $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="skuImg' + (i + 1) + '" class="sku_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\'' + skuInfoImg[i].img_url + '\')" src="' + skuInfoImg[i].img_url + '" width="150" height="150"></span><span id="skuImgId' + (i + 1) + '" style="display: none">' + skuInfoImg[i].img_id + '</span><span id="skuImgUrl' + (i + 1) + '" style="display: none">' + skuInfoImg[i].img_url +
                            '</span>' +
//                            '<div id="btnBox' + (i + 1) + '" class="pt-10 updataBtn">' +
//                            '<a onclick="editPic(' + (i + 1) + ', false)" class="pd-20">修改</a><a onclick="deletePic(' + (i + 1) + ')" class="pd-20">删除</a></div>' +
                            '<div class="pd-20">排序&nbsp;&nbsp;&nbsp;<input type="text" class="input-text radius" onchange="checkRepeat(this, ' + (i + 1) + ')" value="' + skuInfoImg[i].img_sort + '" id="skuImgSort' + (i + 1) + '" name="imgSort" style="width:40px"></div></div>');
                        skuImgCache["img" + (i + 1)] = {
                            imgId: skuInfoImg[i].img_id,
                            imgUrl: skuInfoImg[i].img_url,
                            imgSort: skuInfoImg[i].img_sort
                        };
                    }
                    sessionStorage.setItem("skuImgCache", JSON.stringify(skuImgCache));
                    sessionStorage.setItem("imgLength", JSON.stringify(skuInfoImg.length));
                }
                /*---------------------------------------图片处理结束----------------------------------------*/
            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert(XMLHttpRequest);
        }
    });

    /*tab切换*/
    jQuery.Huitab = function (tabBar, tabCon, class_name, tabEvent, i) {
        var $tab_menu = $(tabBar);
        // 初始化操作
        $tab_menu.removeClass(class_name);
        $(tabBar).eq(i).addClass(class_name);
        $(tabCon).hide();
        $(tabCon).eq(i).show();

        $tab_menu.bind(tabEvent, function () {
            $tab_menu.removeClass(class_name);
            $(this).addClass(class_name);
            var index = $tab_menu.index(this);
            $(tabCon).hide();
            $(tabCon).eq(index).show()
        })
    }
    $(function () {
        $.Huitab("#tab_topnav .tabBar span", "#tab_topnav .tabCon", "current", "click", "0")
    });
    // 1	默认第2个tab为当前状态（从0开始）
    function cancleSku() {
        layer.confirm('确认要取消吗？',function(index){
            sessionStorage.removeItem("skuImgCache");
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
            layer.msg('已取消', {icon: 6,time:1000});
        });
    }
    $(function(){
        $("#sku").Validform({
            tiptype:2,
            callback:function(form){
                img_list();
                return false;
            }
        });
    });

</script>
</html>
